package cn.edu.scau.cmi.chenyipeng.composite.consistent;

import java.util.Set;

public class ConsistentComposite extends ConsistentComponent{
	private String name;
	//private ConsistentComponent parent=null;
	public String doSomething() {
		System.out.println("你好，我是一致型组件");

		return null;
	}

	public ConsistentComponent getParent() {
		return this.parent;
	}

	public Set<ConsistentComponent> getChildren() {
		return getChildren();
	}

	public ConsistentComponent addChild(ConsistentComponent child) {
		System.out.println("现在准备再组合节点中添加子节点");
		this.children.add(child);
		return this;
	}

	@Override
	public ConsistentComponent deleteChild(ConsistentComponent child) {
		children.remove(child);
		return this;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void setParent(ConsistentComponent parent) {
		this.parent = parent;
	}
	
	public String toString() {
		return this.getName();
	}
}
